<template>
  <div id="app">
    <router-view v-if="isRouterAlive"></router-view>
  </div>
</template>

<script>
export default {
  name: 'App',

  mounted() {
    //  var self = this
    // document.onkeydown = function (e) {
    //   var ev = window.event || e
    //   var code = ev.keyCode || ev.which
    //   if (code === 116) { // 禁止页面F5刷新
    //     if (ev.preventDefault) {
    //       ev.preventDefault()
    //       this.reload()
    //     } else {
    //       ev.keyCode = 0
    //       ev.returnValue = false
    //     }
    //   } else if (event.ctrlKey && code === 82) { // 禁用 ctrl+R 刷新
    //     return false
    //     this.isRouterAlive = true
    //   }
    // }.bind(self)
  },
  provide() {
    return {
      reload: this.reload
    }
  },
  data() {
    return {
      isRouterAlive: true
    }
  },
  methods: {
    reload() {
      this.isRouterAlive = false
      this.$nextTick(function() {
        this.isRouterAlive = true
      })
    }
  },
  components: {}
}
</script>

<style lang="scss">
[class^='el-icon-fa'],
[class*=' el-icon-fa'] {
  display: inline-block;
  font: normal normal normal 14px/1 FontAwesome !important;
  font-size: inherit;
  text-rendering: auto;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
</style>
